﻿using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;

namespace WPF_GridSplitter_UI_Demo
{
    public partial class MainWindow : Window
    {
        private Dictionary<string, string> _currentLayoutState;

        public MainWindow()
        {
            InitializeComponent();
            _currentLayoutState = new Dictionary<string, string>();
        }

        private void LayoutComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (LayoutComboBox.SelectedItem is ComboBoxItem selectedItem)
            {
                switch (selectedItem.Content.ToString())
                {
                    case "三格：上 2 下 1":
                        LayoutManager.SetThreeRegionLayoutTop(MainGrid);
                        break;
                    case "三格：下 2 上 1":
                        LayoutManager.SetThreeRegionLayoutBottom(MainGrid);
                        break;
                    case "四格：2x2":
                        LayoutManager.SetFourRegionLayout(MainGrid);
                        break;
                    case "五格：上 3 下 2":
                        LayoutManager.SetFiveRegionLayoutThreeOnTop(MainGrid);
                        break;
                    case "五格：上 2 下 3":
                        LayoutManager.SetFiveRegionLayoutTwoOnTop(MainGrid);
                        break;
                }

                // 保存当前布局
                _currentLayoutState = LayoutManager.SaveLayout(MainGrid);
            }
        }

        private void RestoreLayoutButton_Click(object sender, RoutedEventArgs e)
        {
            LayoutManager.RestoreLayout(MainGrid, _currentLayoutState);
        }
    }
}
